package com.gjt.controller;

import java.sql.*;


/**
 * Created with Intel IDEA.
 * mysql的连接方法
 *
 * @Auther: gjt
 * @Date: 2024/3/11 16:47
 */
public class JdbcMysqlemo {

    public Connection  getConnection() throws ClassNotFoundException, SQLException {
        //1: 导入jar 包
        //2：注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");

        //3：获取数据库连接对象
        Connection connection = DriverManager.getConnection("jdbc:mysql://152.136.138.218:3306/first", "sa", "123456");

        return connection;
    }
}
